﻿using System;
using System.IO;

namespace Moonlite.Data.Configuration
{
    /// <summary>
    /// Provides helper methods for throwing generic exceptions.
    /// </summary>
    internal static class ExceptionHelper
    {
        /// <summary>
        /// Throws a new configuration property attribute not found exception.
        /// </summary>
        /// <param name="propertyName">The name of the property.</param>
        internal static void ThrowConfigurationPropertyAttributeNotFoundException(string propertyName)
        {
            throw new InvalidOperationException(string.Format("All properties in a ConfigurationElement should have the ConfigurationPropertyAttribute applied to them. Property without ConfigurationPropertyAttribute: {0}", propertyName));
        }

        /// <summary>
        /// Throws a new unable to get type from full name exception.
        /// </summary>
        /// <param name="fullname">The full name.</param>
        internal static void ThrowUnableToGetTypeFromFullNameException(string fullname)
        {
            throw new TypeConversionException(string.Format("Unable to get type from fullname '{0}'.", fullname));
        }

        /// <summary>
        /// Throws the <see cref="AppDataOptionsStorer"/> storer wrong file format exception.
        /// </summary>
        internal static void ThrowAppDataOptionsStorerWrongFileFormatException()
        {
            throw new InvalidDataException("The AppDataOptionsStorer's InternalSettingsStorage file was not of the correct binary format.");
        }
    }
}
